﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>最近发起的流程</title>
    <link href="Scripts/bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" />
    <link href="Scripts/bootstrap/css/font-awesome.css" rel="stylesheet">
    <link href="./Style/skin/css/style.css" rel="stylesheet" type="text/css" />
    <link href="./Style/skin/font/iconfont.css" rel="stylesheet" type="text/css" />
</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row c" id="lists">
        </div>
    </div>
    <script type="text/javascript" src="Scripts/bootstrap/js/jquery.min.js"></script>
    <script type="text/javascript" src="Scripts/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="Style/skin/js/mp.mansory.min.js"></script>
    <script src="Scripts/QueryString.js"></script>
    <script src="Scripts/layui/layui/lay/modules/layer.js" type="text/javascript"></script>
    <script src="Scripts/config.js" type="text/javascript"></script>
    <script src="Comm/Gener.js" type="text/javascript"></script>

    <!-- 处理多语言 -->
    <script src="Data/lang/load.js" type="text/javascript"></script>
    <script src="Data/lang/js/zh-cn.js"></script>
    <script src="Data/lang/lang.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">

        function GroupBarClick(groupName) {

            var alt = document.getElementById('Img' + groupName).alert;
            var sta = 'block';
            if (alt == 'Max') {

                sta = 'block';
                alt = 'Min';
                classname = 'fa fa-chevron-down';

            } else {
                sta = 'none';
                alt = 'Max';
                classname = 'fa  fa-chevron-up';
            }

            document.getElementById('Img' + groupName).className = classname;
            document.getElementById('Img' + groupName).alert = alt;

            var i = 0;
            for (i = 0; i <= 600; i++) {

                var row = document.getElementById(groupName + i);

                if (row == null || row == undefined || row.style == null)
                    continue;

                if (sta == 'block') {
                    row.style.display = '';
                } else {
                    row.style.display = sta;
                }
            }
        }
        //发起时打开窗口
        function WinOpenStartFlow(flowNo, title) {

            var showList = GetQueryString("ShowList");
            var url = "";
            if (showList == 1)
                url = "List.htm?FK_Flow=" + flowNo;
            else
                url = "MyFlow.htm?FK_Flow=" + flowNo;

            window.open(url);
            return;

            layer.open({
                skin: 'layer-class',
                type: 2,
                title: title + ' : 发起申请',
                area: ['96%', '90%'],
                content: url
            });
        }

        //查询
        function WinOpenSearch(flowNo, title) {
            var intFlowNo = flowNo;
            var url = "./RptDfine/Default.htm?RptNo=ND" + Number(flowNo) + "RptMy&FK_Flow=" + flowNo;
            window.open(url);
            return;

            layer.open({
                skin: 'layer-class',
                type: 2,
                title: title + ' : 查询主页',
                area: ['96%', '90%'],
                content: url
            });
        }

        //我的流程
        function WinOpenMyFlow(flowNo, title) {
            var intFlowNo = flowNo;
            var url = "Search.htm?RptNo=ND" + Number(flowNo) + "RptMy&FK_Flow=" + flowNo;
            window.open(url);
            return;
        }

        //我发起的流程.
        function WinOpenStart(flowNo, title) {

            var intFlowNo = flowNo;
            var url = "./RptDfine/Search.htm?RptNo=ND" + Number(flowNo) + "RptMy&FK_Flow=" + flowNo + "&SearchType=My";
            window.open(url);
            return;
        }

        function WinOpenList(flowNo, title) {

            var intFlowNo = flowNo;
            var url = "List.htm?RptNo=ND" + Number(flowNo) + "RptMy&FK_Flow=" + flowNo + "&SearchType=My";
            window.open(url);
            return;
        }


        //我发起的流程.
        function WinOpenJoin(flowNo, title) {
            var intFlowNo = flowNo;
            var url = "./RptDfine/Search.htm?RptNo=ND" + Number(flowNo) + "RptMyJoin&FK_Flow=" + flowNo + "&SearchType=MyJoin";
            window.open(url);
            return;
        }

        //批量发起.
        function WinOpenBatch(flowNo, title) {

            var url = "BatchStart.htm?FK_Flow=" + flowNo;
            layer.open({
                skin: 'layer-class',
                type: 2,
                title: title + ' : 批量发起',
                area: ['96%', '90%'],
                content: url
            });
        }


        //页面启动函数.
        $(function () {
            document.title = window.lang.fqxlc;
            InitPage();
            jQuery(document).ready(function ($) {
                $(".c").mpmansory({
                    childrenClass: 'itemt', // default is a div
                    columnClasses: 'paddings', //add classes to items
                    breakpoints: {
                        lg: 4,
                        md: 4,
                        sm: 4,
                        xs: 12
                    },
                    distributeBy: {
                        order: false,
                        height: false,
                        attr: 'data-order',
                        attrOrder: 'asc'
                    }, //default distribute by order, options => order: true/false, height: true/false, attr => 'data-order', attrOrder=> 'asc'/'desc'

                });
            });
        });

        //初始化数据.
        function InitPage() {

            $('#lists').html(window.lang.loading);

            var handler = new HttpHandler("BP.WF.HttpHandler.WF");
            handler.AddUrlData();
            var data = handler.DoMethodReturnString("StartEaryer_Init");
            if (data.indexOf('err@') == 0) {
                alert(data);
                return;
            }

            data = JSON.parse(data);

            //取出来两个结果集.
            var dtSort = data["Sort"]; //类别.
            var dtStart = data["Start"]; //发起的流程.

            var domain = GetQueryString("Domain");

            var myNum = 0;
            var is1 = false;
            var listbox = '';

            for (var i = 0; i < dtSort.length; i++) {

                var sortNo = dtSort[i].No;
                var sortName = dtSort[i].Name;
                var sort = dtSort[i];

                if (domain == '' || domain == null) {

                } else {
                    if (sort.Domain != domain)
                        continue;
                }


                //检查该类别下是否有流程，没有流程就continue ;.
                var isHaveFlow = false;

                for (var idx = 0; idx < dtStart.length; idx++) {

                    var flow = dtStart[idx];
                    if (sortNo == flow.FK_FlowSort) {
                        isHaveFlow = true;
                        break;
                    }
                }

                if (isHaveFlow == false)
                    continue;

                if (sortName == "" || sortName == null)
                    continue;

                listbox += "<div class='itemt' data-order='" + myNum + "'><div class='ibox float-e-margins'><div class='ibox-title'><h5>" + sortName + "</h5><div class='ibox-tools'><a class='collapse-link' data-toggle='collapse'  href='#collapse" + myNum + "'><i class='fa fa-chevron-down' alert='Min' id='Img" + myNum + "' onclick=\"GroupBarClick('" + myNum + "')\"></i></a></div></div><div id='collapse" + myNum + "' class='ibox-contents collapse in'><table class='table table-striped notab'><tbody>";

                var isShowFlows = "";
                //增加处理.
                for (var idx = 0; idx < dtStart.length; idx++) {

                    var flow = dtStart[idx];
                    var flowSort = flow.FK_FlowSort;
                    if (sortNo != flowSort)
                        continue;

                    if (isShowFlows.indexOf(flow.No + ",") != -1)
                        continue;
                    isShowFlows += flow.No + ",";
                    listbox += "<tr><td><a href=\"javascript:WinOpenStartFlow('" + flow.No + "','" + sortName + " - " + flow.Name + "');\" > &sdot; " + flow.No + "." + flow.Name + "</a></td><td class='chooser'><a class='dropdown-toggle' data-toggle='dropdown' href='#'><i class='icon iconfont icon-gongju1'></i></a><ul class='dropdown-menu dropdown-user'>"

                    listbox += "<li><a href=\"javascript:WinOpenList('" + flow.No + "','" + sortName + " - " + flow.Name + "');\" >列表发起</a></li>";

                    if (flow.IsBatchStart == "1")
                        listbox += "<li><a href=\"javascript:WinOpenBatch('" + flow.No + "','" + sortName + " - " + flow.Name + "');\" >批量发起</a></li>";


                    listbox += "<li><a href=\"javascript:WinOpenStart('" + flow.No + "','" + sortName + " - " + flow.Name + "');\" >我发起的流程</a></li>";
                    listbox += "<li><a href=\"javascript:WinOpenJoin('" + flow.No + "','" + sortName + " - " + flow.Name + "');\" >我审批的流程</a></li>";
                    listbox += "<li><a href=\"javascript:WinOpenMyFlow('" + flow.No + "','" + sortName + " - " + flow.Name + "');\" ><font color=red>*</font>我的流程</a></a></li>";
                    listbox += "<li><a href=\"javascript:WinOpenSearch('" + flow.No + "','" + sortName + " - " + flow.Name + "');\" >查询主页</a></li></ul></td></tr>";

                }
                listbox += '</tbody></table></div></div></div>';
                myNum++;
            }
            $('#lists').html(listbox);
        }

        function Ref() {
            SetHref('Start.htm?IsRef=1');
        }
    </script>
</body>
</html>
